from django.db import models
from django.contrib.auth.models import User
from fiteat.utils import Constants, K
import multilingual
from django.utils.translation import ugettext as _

EXERCISE_TYPES = Constants(
    K(cable=1, label=_('Cable')),
    K(barbell=2, label=_('Barbell')),
    K(dumbells=3, label=_('Dumbbells')),
    K(lever=4, label=_('Lever')),
    K(weighted=5, label=_('Weighted')),
    K(smith=6, label=_('Smith')),
    K(assisted=7, label=_('Assisted')),
# Other types?
)

UTILITY_CHOICES = Constants(
    K(basic=1, label=_('Basic')),
    K(auxiliary=2, label=_('Auxiliary')),
)

MECHANICS_CHOICES = Constants(
    K(compount=1, label=_('Compound')),
    K(isolated=2, label=_('Isolated')),
)

FORCE_CHOICES = Constants(
    K(push=1, label=_('Push')),
    K(pull=2, label=_('Pull')),
)

class MuscleGroup(models.Model):
    dummy_field = models.IntegerField(_('dummy'), null=True, blank=True)
    class Translation(multilingual.Translation):
        name = models.CharField(_('name'), max_length=50)

    def __unicode__(self):
        return self.name

    class Admin:
        pass

class Muscle(models.Model):
    group = models.ForeignKey(MuscleGroup, verbose_name=_('Muscle group'))
    class Translation(multilingual.Translation):
        name = models.CharField(_('name'), max_length=50)

    def __unicode__(self):
        return self.name

    class Admin:
        pass

class Exercise(models.Model):
    name = models.CharField(_('name'), max_length=50)
    added_by = models.ForeignKey(User, verbose_name=_('added by'), blank=True, editable=False)
    added_on = models.DateField(_('added on'))
    agonist = models.ManyToManyField(Muscle, verbose_name=_('agonist'), related_name='agonist')
    antagonist = models.ManyToManyField(Muscle, verbose_name=_('antagonist'), related_name='antagonist')
    target = models.ForeignKey(Muscle, verbose_name=_('target'), related_name='target')
    synergist = models.ManyToManyField(Muscle, verbose_name=_('synergist'), related_name='synergist')
    stabilizer = models.ManyToManyField(Muscle, verbose_name=_('stabilizer'), related_name='stabilizer')
    dynamic_stabilizer = models.ManyToManyField(Muscle, verbose_name=_('dynamic_stabilizer'), related_name='dynamic_stabilizer')
    antagonist_stabilizer = models.ManyToManyField(Muscle, verbose_name=_('antagonist_stabilizer'), related_name='antagonist_stabilizer')
    image = models.ImageField(_('image'), upload_to='/tmp')
    instructions = models.CharField(_('instructions'), max_length=250)
    type = models.IntegerField(_('type'), choices=EXERCISE_TYPES.choices())
    utility = models.IntegerField(_('utility'), choices=UTILITY_CHOICES.choices())
    class Admin:
        pass

class Stretch(models.Model):
    pass

#class ScheduledExercise(models.Model):
#    exercise = models.ForeignKey(Exercise)
#    workout = models.ForeignKey(Workout)
#
#class Workout(models.Model):
#    user = models.ForeignKey(User)
#    name = models.CharField(_('name'), max_length=50)
#    exercises = models.ManyToManyField(Exercise, verbose_name=_('exercises'), related_name='exercises')
#
#    class Admin:
#        pass

class Strength(models.Model):
    user = models.ForeignKey(User, blank=True, editable=False)
    date = models.DateField(_('date'))

